package org.bees.cms.web.listener;

import java.util.Properties;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.bees.cms.common.Files;
import org.bees.cms.web.util.velocity.Configuration;

public class ContextLifecycleListener implements ServletContextListener {

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		ServletContext context = sce.getServletContext();
		Configuration.initialize(context);

		Properties properties = new Properties();
		properties.setProperty("context.root", context.getRealPath(context.getContextPath()));
		Files.config(properties);
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		Configuration.destroy();
		Files.destroy();
	}

}
